@extends('public.dashboard_base')
@section('title', '修改密码')

@section('content')
    @php
        $user =auth('admin')->user();
    @endphp
    <div class="control_panel_content">
        <div class="navBreadcrumb">
            <ul>
                <li>账户管理</li>
                <li>安全中心</li>
                <li>修改密码</li>
            </ul>
        </div>
        <div class="panel">
            <div class="sub_nav_container">
                <ul class="clearfix">
                    <li class="active"><a href="javascript:;">修改密码</a></li>
                </ul>
            </div>
            <div class="panel_body">
                <form id="update_password_form" action="/account/edit/pw" method="post">
                    {{csrf_field()}}
                    <ul class="form_group">
                        <li>
                            <span class="form_label">当前密码</span>
                            <input type="password" name="password">
                        </li>
                        <li>
                            <span class="form_label">新密码</span>
                            <input type="password" name="newPassword">
                        </li>
                        <li>
                            <span class="form_label">确认新密码</span>
                            <input type="password" name="confirmNewPassword">
                        </li>
{{--                        <li>--}}
{{--                            <span class="form_label">手机号码</span>--}}
{{--                            <div style="width: 280px;display: inline-block;vertical-align: middle;height: 32px;line-height: 26px;">--}}
{{--                                <span style="vertical-align: middle">15166664603</span>--}}
{{--                                <input type="button" id="sms_send" class="btn btn_default fr" value="获取验证码">--}}
{{--                            </div>--}}
{{--                        </li>--}}
{{--                        <li>--}}
{{--                            <span class="form_label">验证码</span>--}}
{{--                            <input type="text" name="authCode">--}}
{{--                        </li>--}}
                        <li>
                            <span class="form_label">&nbsp;</span>
                            <input type="submit" class="btn btn_primary" value="修改">&nbsp;
                            <input type="button" class="btn btn_default" onclick="return window.history.go(-1)" value="返回">
                        </li>
                    </ul>
                </form>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script>
        $(function () {
            var link=  $("#account-safe");
            link.parent().parent().parent().addClass("active");
            link.parent().addClass("active");

            $("#update_password_form").validate({
                rules: {
                    password: {
                        required: true,
                        minlength:6,
                    },
                    newPassword: {
                        required: true,
                        minlength:6,
                    },
                    confirmNewPassword: {
                        required: true,
                        minlength:6,
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        success: function (data) {
                            if (data.msg === 'success') {
                                layer.msg('成功!', {icon: 1, time: 1000}, function () {
                                  //  window.location = '/account/auth/email';
                                    window.history.go(-1);
                                })
                            } else {
                                layer.msg(data.data.error, {icon: 2, time: 1000,});
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('server error!', {icon: 2, time: 1000}, function () {
                            });
                        }
                    });
                }
            });
        });
    </script>
    @endsection
